import 'babel-polyfill'
import Vue from 'vue'
import store from '@/store'
import App from './App'
import router from '@/router'
import VueLazyload from 'vue-lazyload'
import GMessage from '@/components/common/g-message'
import GNotification from '@/components/common/g-notification'
import GMessageBox from '@/components/common/g-message-box'
import {
  Base64
} from 'js-base64';

import ElementUI from 'element-ui';
import "@/assets/iconfont/iconfont.css";
import 'element-ui/lib/theme-chalk/index.css';

import "geohey-javascript-sdk/dist/lib/g.css";
import G from "geohey-javascript-sdk";
import "geohey-javascript-sdk/dist/lib/g-canvas.min.js";
import "geohey-javascript-sdk/dist/lib/g-draw.min.js";
import "geohey-javascript-sdk/dist/lib/g-heat.min.js";
import "geohey-javascript-sdk/dist/lib/g-maps.min.js";
import "geohey-javascript-sdk/dist/lib/g-temporal.min.js";
import "geohey-javascript-sdk/dist/lib/g-anim.min.js";
import "geohey-javascript-sdk/dist/lib/g-fluid.min.js";
import "geohey-javascript-sdk/dist/lib/g-mapviz.min.js";
import "geohey-javascript-sdk/dist/lib/g-movable.min.js";
import "geohey-javascript-sdk/dist/lib/g-cluster.min.js";
import "geohey-javascript-sdk/dist/lib/g-dataviz.min.js";
import mapUtil from "@/utils/mapUtil.js";
import mapExtend from "@/utils/mapExtend.js";

// import extend_axios from '@/utils/extend_axios.js';

Vue.use(ElementUI);

Vue.config.productionTip = false;

Vue.prototype.$message = GMessage;
/**
 * 使用方式：
 * 1. this.$message( 'msg' )
 * 2. this.$message( { type: 'info', message: 'msg', duration: 3000 } )    // type: info success error warning
 * 3. this.$message.info( 'msg' ) 或 this.$message.error( 'msg' )    // 还有 .success .warning
 */

Vue.prototype.$notify = GNotification;
// 使用方式和message类似

Vue.prototype.$alert = GMessageBox.alert;

Vue.prototype.$confirm = GMessageBox.confirm;

Vue.prototype.$prompt = GMessageBox.prompt;

Vue.use(VueLazyload, {
  // loading: '../../static/img/loading.svg',
  attempt: 1
})

new Vue({
  el: '#app',
  store,
  data() {
    let dataCategory = window['geohey_data_data_category'] ? JSON.parse(Base64.decode(window['geohey_data_data_category'])) : null;
    let adminRegion = window['geohey_data_admin_region'] ? JSON.parse(Base64.decode(window['geohey_data_admin_region'])) : null;
    // let componentConf = window['geohey_data_component_conf'] ? JSON.parse(Base64.decode(window['geohey_data_component_conf'])) : null;
    let showWgs84DownloadOption = window['geohey_data_show_wgs84_download_option'];
    let componentConf = null;
    return {
      geohey: {
        user: JSON.parse(Base64.decode(window['geohey_data_user'])),
        plan: JSON.parse(Base64.decode(window['geohey_data_plan'])),
        upload_limit: JSON.parse(Base64.decode(window['geohey_data_upload_limit'])),
        backend_env: window['backend_env']
      },
      org: JSON.parse(Base64.decode(window['geohey_org'])),
      dataCategory: dataCategory,
      adminRegion: adminRegion,
      componentConf: componentConf,
      showWgs84DownloadOption: showWgs84DownloadOption
    }
  },
  router,
  render: h => h(App)
});
